From e1779aeaa7a463dde93b31297de3462a54d07ade Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 15 Nov 2022 01:44:28 +0100 Subject: [PATCH] luci-mod-network: restrict peerdns option to protocols that implemenent it Only some supported protocol extensions honour the `peerdns` options. Fixes: #6093 Signed-off-by: Jo-Philipp Wich (cherry picked from commit 2be01cbfcb34746d9713173a60c3f8a69c554a68) --- .../resources/view/network/interfaces.js | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js index d5f9060114..d44b0cf6d0 100644 --- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js +++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js @@ -228,6 +228,22 @@ function get_netmask(s, use_cfgvalue) { return subnetmask; } +function has_peerdns(proto) { + switch (proto) { + case 'dhcp': + case 'qmi': + case 'ppp': + case 'pppoe': + case 'pppoa': + case 'pptp': + case 'openvpn': + case 'sstp': + return true; + } + + return false; +} + var cbiRichListValue = form.ListValue.extend({ renderWidget: function(section_id, option_index, cfgvalue) { var choices = this.transformChoices(); @@ -936,13 +952,13 @@ return view.extend({ o = nettools.replaceOption(s, 'advanced', form.Flag, 'defaultroute', _('Use default gateway'), _('If unchecked, no default route is configured')); o.default = o.enabled; - if (protoval != 'static') { + if (has_peerdns(protoval)) { o = nettools.replaceOption(s, 'advanced', form.Flag, 'peerdns', _('Use DNS servers advertised by peer'), _('If unchecked, the advertised DNS server addresses are ignored')); o.default = o.enabled; } o = nettools.replaceOption(s, 'advanced', form.DynamicList, 'dns', _('Use custom DNS servers')); - if (protoval != 'static') + if (has_peerdns(protoval)) o.depends('peerdns', '0'); o.datatype = 'ipaddr'; -- 2.30.2